//go:build wireinject

// Package main
// Created by GoLand
// @User: lenora
// @Date: 2024/8/27
// @Time: 15:33
package main

import (
	"camp/microbook/interactive/events"
	"camp/microbook/interactive/grpc"
	"camp/microbook/interactive/ioc"
	"camp/microbook/interactive/repository"
	"camp/microbook/interactive/repository/cache"
	"camp/microbook/interactive/repository/dao"
	"camp/microbook/interactive/service"
	"github.com/google/wire"
)

var thirdParty = wire.NewSet(
	ioc.InitLogger,
	//第三方依赖
	ioc.InitDb, ioc.InitRedis, ioc.InitSaramaClient, ioc.InitSyncProducer, ioc.InitConsumers,
)

var interactiveSvcSet = wire.NewSet(
	dao.NewGORMInteractiveDAO,
	cache.NewInteractiveRedisCache,
	repository.NewInteractiveRepository,
	service.NewInteractiveService,
)

func InitApp() *App {
	wire.Build(
		thirdParty,
		interactiveSvcSet,
		grpc.NewInteractiveServer,
		events.NewInteractiveReadConsumer,
		ioc.NewGrpcXServer,
		wire.Struct(new(App), "*"),
	)
	return new(App)
}
